package com.zxgllhh.run;

import java.util.ArrayList;
import java.util.List;

import com.zxgllhh.domain.Table;
import com.zxgllhh.generator.ActionGenarator;
import com.zxgllhh.generator.DaoGenarator;
import com.zxgllhh.generator.DaoImplGenarator;
import com.zxgllhh.generator.DomainGenarator;
import com.zxgllhh.generator.FormGenarator;
import com.zxgllhh.generator.ListGenarator;
import com.zxgllhh.generator.MapsGenarator;
import com.zxgllhh.generator.ServiceGenarator;
import com.zxgllhh.generator.ServiceImplGenarator;
import com.zxgllhh.generator.ViewGenarator;

public class TableGeneratorThread extends Thread {
	
	private static int count = 0;
	
	private String databaseName;
	
	private List<Table> tableList = new ArrayList<Table>();
	
	public void run() {
		long time = System.currentTimeMillis();
		count++;
		for(Table table : tableList){
			try {
				ActionGenarator.go(table);
				DomainGenarator.go(table);
				DaoGenarator.go(table);
				DaoImplGenarator.go(table);
				MapsGenarator.go(table,databaseName);
				ServiceGenarator.go(table);
				ServiceImplGenarator.go(table);
				ListGenarator.go(table);
				FormGenarator.go(table);
				ViewGenarator.go(table);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		System.out.println("file " + (System.currentTimeMillis() - time) + " milliseconds");
	}

	public String getDatabaseName() {
		return databaseName;
	}

	public void setDatabaseName(String databaseName) {
		this.databaseName = databaseName;
	}

	public List<Table> getTableList() {
		return tableList;
	}

	public void setTableList(List<Table> tableList) {
		this.tableList = tableList;
	}
}
